﻿//
// Created by francklinson on 2021/3/13.
//

#include <iostream>

int main()
{
    using namespace std;
    double *p3 = new double[3];  // space for 3 doubles
    p3[0] = 0.2;                   // treat p3 like an array name 像使用数组名一样使用指针
    p3[1] = 0.5;
    p3[2] = 0.8;
    cout << "p3[1] is " << p3[1] << ".\n";
    p3 = p3 + 1;                  // increment the pointer 移动指针  数组名不可修改，但指针可以修改
    cout << "Now p3[0] is " << p3[0] << " and ";
    cout << "p3[1] is " << p3[1] << ".\n";
    p3 = p3 - 1;                 // point back to beginning
    delete[] p3;                // free the memory
    return 0;
}